package com.xinxing.learning.crypto.keyresolver.impl;

import cn.hutool.crypto.symmetric.AES;
import com.xinxing.learning.crypto.keyresolver.InterfaceKeyresolver;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;

@Slf4j
@Component
public class AESInterfaceKeyresolver implements InterfaceKeyresolver {

    @Resource
    private AES iocAes;

    @Override
    public String encryptHex(String data) {
        log.info("encryptHex() called with parameters => 【data = {}】", data);
        return iocAes.encryptHex(data, StandardCharsets.UTF_8);
    }

    @Override
    public String decrypt(String data) {
        log.info("decrypt() called with parameters => 【data = {}】", data);
        return iocAes.decryptStr(data, StandardCharsets.UTF_8);
    }
}
